﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using Microsoft.Commerce.Contracts;

namespace MusicWorks.Service.DataContracts
{
    
 
    public class UserProfile : BaseCommerceEntity
    {

        public const string ModelNameDefintion = "UserProfile";

        public UserProfile()
        {
            this.CommerceEntity = new CommerceEntity(ModelNameDefintion);
        }

        public UserProfile(CommerceEntity commerceEntity) : base(commerceEntity)
        {
            this.CommerceEntity = commerceEntity;
        }

        public static implicit operator UserProfile(CommerceEntity commerceEntity)
        {
            return new UserProfile(commerceEntity);
        }

        /// <summary>
        /// Gets or sets the user's last name.
        /// </summary>
        /// <value>The last name.</value>
        public string LastName
        {
            get { return _commerceEntity.GetPropertyValue(PropertyName.LastName) as string; }
            set { _commerceEntity.SetPropertyValue(PropertyName.LastName, value); }
        }

        /// <summary>
        /// Gets or sets the user's first name.
        /// </summary>
        /// <value>The first name.</value>
        public string FirstName
        {
            get { return _commerceEntity.GetPropertyValue(PropertyName.FirstName) as string; }
            set { _commerceEntity.SetPropertyValue(PropertyName.FirstName, value); }
        }


        /// <summary>
        /// Gets or sets the user address list.
        /// </summary>
        /// <value>The addresses.</value>
        public CommerceRelationshipList Addresses
        {
            get { return _commerceEntity.GetPropertyValue(RelationshipName.Addresses) as CommerceRelationshipList; }
            set { _commerceEntity.SetPropertyValue(RelationshipName.Addresses, value); }
        }

        /// <summary>
        /// Gets or sets the preferred address for this user.
        /// </summary>
        /// <value>The preferred address.</value>
        public CommerceRelationship PreferredAddress
        {
            get { return _commerceEntity.GetPropertyValue(RelationshipName.PreferredAddress) as CommerceRelationship; }
            set { _commerceEntity.SetPropertyValue(RelationshipName.PreferredAddress, value); }
        }



        public class PropertyName : CommerceEntity.PropertyName
        {
            public static string LastName  = "LastName";
            public static string FirstName = "FirstName";
                
        }
        public class RelationshipName
        {
            public static string PreferredAddress = "PreferredAddress";

            /// <summary>
            /// The name of the Addresses property for an item related to a UserProfile.
            /// </summary>
            public const string Addresses = "Addresses";                

        }
    }
}
